package com.heima.feigns.fallback;

import com.heima.feigns.ApArticleClient;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author yunfei
 * @date 2022年10月20日 9:50
 */
@Component
public class ApArticleClientFallback implements FallbackFactory<ApArticleClient> {

    @Override
    public ApArticleClient create(Throwable cause) {
        return new ApArticleClient() {
            @Override
            public ResponseResult saveArticle(ArticleDto articleDto) {
                return ResponseResult.errorResult(5000,"ApArticleClient的saveArticle远程调用失败");
            }

            @Override
            public ResponseResult findOneById(long articleId) {
                return ResponseResult.errorResult(5000,"ApArticleClient的saveArticle远程调用失败");
            }

            @Override
            public ResponseResult findAll() {
                return ResponseResult.errorResult(5000,"ApArticleClient的saveArticle远程调用失败");
            }

            @Override
            public ResponseResult selectFiveDaysArticle() {
                return ResponseResult.errorResult(5000,"ApArticleClient的saveArticle远程调用失败");
            }
        };
    }
}
